package dbPhase.hypeerweb;

/**
 * UpPointerRole extends Connection and overrides all the methods to change the connections
 * in reference as a Uppointer.
 *
 * @see Connection
 *
 *
 *
 */
public class UpPointerRole extends Connection {
	public UpPointerRole(Node n, Node b) {
		super(n, b);
	}

	@Override
	public void addConnection(Node newNode) {
		delegate.upPointers.add(newNode);
		newNode.downPointers.add(delegate);
		delegate.nodeState = UpPointingNodeState.getSingleton();
	}

	@Override
	public void removeConnection(Node remove) {
		delegate.downPointers.remove(remove);
		remove.upPointers.remove(delegate);


	}

	@Override
	public void replaceConnection(Node oldNode, Node newNode) {
	//	System.out.println("\t\tUPROLE"+ oldNode.getWebIdValue()+ " , "+ newNode.getWebIdValue());
	//	System.out.println("\t\tDelegate"+ delegate.getWebIdValue());
		delegate.downPointers.remove(oldNode);
		oldNode.upPointers.remove(delegate);
		delegate.downPointers.add(newNode);
		newNode.upPointers.add(delegate);
	}
}
